<?php
/* FUNCIONES y METODOS FUNCIONES PARA EL DEBUG */

/* Debug de todos los Hooks de Wordpress. Muestra un listado con todos los Hooks que Wordpress, indicando que metodos y funciones tienen anexados y sus respectivas prioridades de ejecucion */

function list_hooked_functions($tag=false) {
	global $wp_filter;

	if($tag) :
		$hook[$tag] = $wp_filter[$tag];
		
		if(!is_array($hook[$tag])) :
			trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
			return;
		endif;
	else :
		$hook = $wp_filter;
		ksort($hook);
	endif;
	
	echo '<pre>';
	
		foreach($hook as $tag => $priority) :
			echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag</strong><br />";
			
			ksort($priority);
			
			foreach($priority as $priority => $function) :
				echo $priority;
				
				foreach($function as $name => $properties)
					echo "\t$name<br />";
  			endforeach;
 		endforeach;
 		
	echo '</pre>';
	
	return;
}
//add_action('admin_footer', 'list_hooked_functions');
//add_action('wp_footer', 'list_hooked_functions');

/* Genera un print_r() mas estilizado y entendible */

function dump() {
	global $wp_query, $post, $ft;
	
	$data = $ft;
	
    if(is_array($data)) : //If the given variable is an array, print using the print_r function.
        print "<pre>-----------------------\n";
        print_r($data);
        print "-----------------------</pre>";
    elseif (is_object($data)) :
        print "<pre>==========================\n";
        var_dump($data);
        print "===========================</pre>";
    else :
        print "=========&gt; ";
        var_dump($data);
        print " &lt;=========";
    endif;
}
//add_action('admin_footer', 'dump');
//add_action('wp_footer', 'dump');
?>